package com.hand.test.controller;/**
 * @author Estelle@앙수청
 * @date 2019/7/20 9:30
 */

import com.hand.test.domain.Matter;
import com.hand.test.domain.StoreDTO;
import com.hand.test.service.MatterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  @author Estelle@앙수청
 *  @date 2019/7/20 9:30
 */
@RestController
@RequestMapping("/matter")
public class MatterController {

    @Autowired
    private MatterService matterService;

    @GetMapping(value = "/all")
    public ResponseEntity<List<Matter>> getAllUser(){
        return ResponseEntity.ok(matterService.queryAllMatter());
    }

    @GetMapping(value = "/{id}")
    public ResponseEntity<Matter> getUserById(@PathVariable("id") Integer id){
        return ResponseEntity.ok(matterService.queryMatterById(id));
    }

    @PostMapping
    public ResponseEntity<Integer> addUser(@RequestBody Matter matter){
        return ResponseEntity.ok(matterService.addMatter(matter));
    }

    @PutMapping
    public ResponseEntity<Void> updateUser(@RequestBody Matter matter){
        matterService.updateMatter(matter);
        return ResponseEntity.ok().build();
    }

    @DeleteMapping(value = "/{id}")
    public ResponseEntity<Void> deleteUser(@PathVariable("id") Integer id){
        matterService.deleteMatter(id);
        return ResponseEntity.ok().build();
    }

}
